<?php
define("SYS_PATH",dirname(__FILE__)."/");

include_once 'giftcert/lib/Common.php';
include_once 'giftcert/lib/CheckInput.php';

//start session
session_start();

//get gateway config
$gateway = Common::gatewayConfig();

//quote value in post, get, session, cookies.
Common::checkMagicQuotes();

$errArray = null;

//if exist GET SID var
if( isset($_GET['SID']) == true)
{
	//if session id not equal get.
	if( $_SESSION['inputArray']['SID'] != $_GET['SID'] )
	{
		$_SESSION['inputArray'] = null;
	}
	else//back from PayPal when transaction not complete.
	{
		$outputArray = $_SESSION['inputArray'];
	}
}

//if is post
if(isset($_POST['u_name']) == true)
{
	//get post params
	$inputArray = array();
	$inputArray['uName'] = $_POST['u_name'];
	$inputArray['uEmail'] = $_POST['os0'];
	$inputArray['rName'] = $_POST['r_name'];
	$inputArray['rEmail'] = $_POST['r_email'];
	$inputArray['rMessage'] = $_POST['r_message'];
	$inputArray['location'] = $_POST['location'];
	$inputArray['template'] = $_POST['chkTemplate'];
	$inputArray['chkEmail'] = $_POST['chkEmail'];
	$outputArray = 	$inputArray;
}

//check input
$errArray = CheckInput::check($inputArray);
if( isset($inputArray) == TRUE && isset($errArray) == FALSE)
{
	//save to session
	$token = strtoupper(md5(uniqid(rand(),true)));
	$inputArray['SID'] = $token;
	$_SESSION['inputArray'] = $inputArray;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>PayPal is the safer, easier way to pay - PayPal</title>
<style type="text/css" media="screen">
	@import url("./navbar.css");
	@import url("./styles.css");
	.imgTpl{
	border:1px solid black;
	}
	div.error{
		color: red;
		font-size:11px
	}
}
</style>

</head>
<body>
<center>
<br><br><br>
<img src="images/gift_cert/loading.gif"><br>
Loading...
</center>
<form action="https://<?php echo $gateway["gateway_url"]; ?>./cgi-bin/webscr" method="post" id="paypalFrm">
<input type="hidden" name="cmd" value="_xclick">

<input type="hidden" name="business" value="<?php echo $gateway["merchant_acc"]; ?>">

<input type="hidden" name="item_name" value="Electronic Gift Certificate">

<input type="hidden" name="page_style" value="Primary">

<input type="hidden" name="no_shipping" value="1">

<input type="hidden" name="return" value="<?php echo Common::getAddress(); ?>gift-certificates-3.php">

<input type="hidden" name="notify_url" value="<?php echo Common::getAddress(); ?>gift-certificates-3.php">

<input type="hidden" name="cancel_return" value="<?php echo Common::getAddress(); ?>gift-certificates-2.php?SID=<?php echo $token; ?>">

<!-- <input type="hidden" name="cn" value="Message to Recipient"> -->

<input type="hidden" name="currency_code" value="USD">

<input type="hidden" name="lc" value="US">

<input type="hidden" name="rm" value="2">

<input type="hidden" name="on0" value="Recipient's name">

<input type="hidden" name="os0" value="
<?php 
echo htmlspecialchars($inputArray['rName']);
echo (strlen($inputArray['rEmail'])>0)?"(".htmlspecialchars($inputArray['rEmail']).")":"" ;
?>">

<input type="hidden" name="on1" value="SID">

<input type="hidden" name="os1" value="<?php echo $token; ?>">

<script type="text/javascript">
var frm = document.getElementById('paypalFrm');
frm.submit();
</script>

</form>
</body>
</html>
<?php
}
else
{
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>

<title>Digital Photography Services - Digital Imaging Services</title>
<meta name="verify-v1" content="N/yxUL4E2rQx8gpq7ivVQeX/HKfddPvCAsf3Pihde9c=" />
<META name = "description" content= "Professional digital photography services and digital film services by Digital Pickle.  We scan photos, slides and negatives, and digitizes audio, video, and film or sharing, preservation, and restoration. Reliable digital photography service nationwide." />
<META name= "keywords" content= "digital photography services, digital imaging services, digital film services, digital scanning services, digital imaging solutions, digitalpickle" />
<meta http-equiv="Content-Language" content="en-us" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />


<link rel="shortcut icon" href=" dp.ico" />
<link href="dpstyles.css" rel="stylesheet" type="text/css" />


<style type="text/css" media="screen">
	@import url("./navbar.css");
	@import url("./styles.css");
	.imgTpl{
	border:1px solid black;
	}
	div.error{
		color: red;
		font-size:11px
	}
}
</style>

<script type="text/javascript" src="js/prototype.js"></script>
<script type="text/javascript" src="js/scriptaculous.js?load=effects,builder"></script>
<script type="text/javascript" src="js/lightbox.js"></script>

<script type="text/javascript" src="js/common.js"></script>

<link rel="stylesheet" href="css/lightbox.css" type="text/css" media="screen" />

<!--js and css needed for lightbox BEGIN -->
<link rel="stylesheet" href="css/overlayBox.css" media="screen,projection" type="text/css" />
<link rel="stylesheet" href="css/lightbox.css" media="screen,projection" type="text/css" />

<script src="Scripts/prototype.js" type="text/javascript"></script>
<script src="Scripts/lightbox.js" type="text/javascript"></script>
<!--js and css needed for lightbox END -->


<!--[if IE 5]>
<style type="text/css"> 
/* place css box model fixes for IE 5* in this conditional comment */
.centerCol #sidebar1 { width: 220px; }
</style>
<![endif]--><!--[if IE]>
<style type="text/css"> 
/* place css fixes for all versions of IE in this conditional comment */
.centerCol #sidebar1 { padding-top: 30px; }
.centerCol #mainContent { zoom: 1; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]-->

<script type="text/javascript">
<!--
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>

<!--[if lte IE 6]>
<script type="text/javascript" src="Scripts/supersleight-min.js"></script>
<![endif]-->
</head>

<body class="centerCol" onLoad="MM_preloadImages('includes/images/myproject_on.gif','includes/images/services_on.gif','includes/images/howitworks_on.gif','includes/images/aboutus_on.gif','includes/images/testimonials_on.gif','includes/images/prices_on.gif','includes/images/photoscanning_on.gif','includes/images/videotransfer_on.gif','includes/images/filmtransfer_on.gif','includes/images/audiotransfer_on.gif','includes/images/dvdslideshows_on.gif','includes/images/restoration_on.gif','includes/images/photogifts_on.gif','includes/images/proservices_on.gif')">

<div id="container">
<?php include("includes/header.html"); ?>
<div id="twoColContainer">
  <div id="sidebar1">
  <?php include("includes/aff_and_assoc.html"); ?>
  </div>
<!-- end #sidebar1 -->

  <div id="mainCol">
  
  
  <img src="images/pagetitle_giftcert.png" alt="gift certificates" width="735" height="60" id="serviceTitle"/>

    
  <div class="miniContainer">
    <h4>Gift Certificates for Digital Services</h4>

    <p><img src="images/gift_cert_sm.jpg" width="178" height="87" alt="picture of photobook" class="imgWhiteBorder"/>Photo and video preservation is a truly unique and valuable gift for anyone who treasures memories. You can purchase a gift certificate for any amount and it is redeemable for any products or services provided by Digital Pickle. Each gift certificate includes the recipient's name, your name, and a personal message from you to the recipient.<br /><br />

An electronic gift certificate will be emailed to you and optionally to the recipient.<br /><br />
<img src="images/logo_paypal.jpg" alt="picture of photobook" width="119" height="50" border="0" class="imgWhiteBorder"/>
Payment is made through Paypal using your credit card (Visa, MasterCard, Discover, American Express, or electronic check). After the transaction is complete you will receive an electronic receipt. To redeem the gift the recipient will print out the gift certificate and include it with his material that he/she will either bring over or send to the selected studio (San Francisco or Los Angeles).</p>
  </div>
    <div class="miniContainer">
    <h4>Terms &amp; Conditions</h4>

    <p>1. Gift certificates can be redeemed for any Digital Pickle products or services, except for gift certificates.<br />
      2. Gift certificates do not expire.<br />
      3. Any unused balance will be placed in the recipient’s gift certificate account for future use or transfer.<br />
      4. If your order exceeds the amount of your gift certificate, you must pay for the balance.<br />
      5. Gift certificates are not redeemable for cash and cannot be returned for a cash refund.</p>
  </div>
  
<div class="miniContainerEmpty">

<!--<form action="https://www.paypal.com/cgi-bin/webscr" method="post">-->
<!--<form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">-->

  <form action="" method="post">
 <table border="0" cellpadding="5" cellspacing="5" align="left" id="giftCertTable">
<tr height="40">
<td><strong>Order Gift Certificate
</strong></td>
</tr>

<tr height="40"><td>Your name:<br />
<input type="text" maxlength="50" name="u_name" id="u_name" size="50" value="" />
<div id="uNameErr" class="error"><?php echo htmlspecialchars($errArray['uNameErr']); ?></div>
</td></tr>

<tr height="40"><td width="200">Your email address:<br />

<input type="text" maxlength="50"  name="os0" id="u_email" size="50" value="" />
<div id="uEmailErr" class="error"><?php echo htmlspecialchars($errArray['uEmailErr']); ?></div>
</td></tr>

<tr height="40"><td>Recipient's name:<br />
<input type="text" maxlength="50" name="r_name" id="r_name" size="50" value="" />
<div id="rNameErr" class="error"><?php echo htmlspecialchars($errArray['rNameErr']); ?></div>
</td></tr>

<tr height="40" valign="top"><td>Email gift certificate to recipient:
<input type="checkbox" id="chkEmail" name="chkEmail" value="1" checked="checked" onClick="showEmailBox();" />
<br /><br />
<div id="emailRow">
	Recipient's email address:<br />

<input type="text" name="r_email" maxlength="50" id="r_email" size="50" value="" />
<div id="rEmailErr" class="error"><?php echo htmlspecialchars($errArray['rEmailErr']); ?></div>
</div>
</td></tr>

<tr height="40"><td>Message: (Maximum Message Length 50 Characters)<br />
<textarea name="r_message" id="r_message" cols="38" rows="2"  maxlength="50" onKeyDown="return ismaxlength(this,event);"  onkeyup="return limitMsg(this,event);"  oncontextmenu="return false;"></textarea>
<div id="rMessageErr" class="error"><?php echo htmlspecialchars($errArray['rMessageErr']); ?></div>
</td></tr>

<tr height="40"><td>Redemption location:
<input type="radio" name="location" id="loSF" checked="checked" value="SF" />San Francisco 
<input type="radio" name="location" id="loLA" value="LA" />Los Angeles
</td></tr>

<tr><td>
Certificate design (click on thumbnail to see full size image):<br /><br />

<table border="0">
<tr><td>

<img src="giftcert/images/tpl1thumb.jpg" width="241" height="102" border="0" /></td>
<td width="50">&nbsp;</td>
<td><img src="giftcert/images/tpl2thumb.jpg" width="241" height="102" /></td></tr>
<tr><td align="center"><input type="radio" name="chkTemplate" id="tpl1" value="tpl1" checked="checked" /></td>
<td>&nbsp;</td>
<td align="center"><input type="radio" name="chkTemplate" id="tpl2" value="tpl2" /></td></tr>

<tr><td><img src="giftcert/images/tpl3thumb.jpg" width="241" height="102" /></td>
<td>&nbsp;</td>
<td><img src="giftcert/images/tpl4thumb.jpg" width="241" height="102" /></td></tr>

<tr><td align="center"><input type="radio" name="chkTemplate" id="tpl3" value="tpl3" /></td>
<td>&nbsp;</td>
<td align="center"><input type="radio" name="chkTemplate" id="tpl4" value="tpl4" /></td></tr>

<tr><td><img src="giftcert/images/tpl5thumb.jpg" width="241" height="102" /></td>
<td>&nbsp;</td>
<td><img src="giftcert/images/tpl6thumb.jpg" width="241" height="102" /></td></tr>
<tr><td align="center"><input type="radio" name="chkTemplate" id="tpl5" value="tpl5" /></td>
<td>&nbsp;</td>
<td align="center"><input type="radio" name="chkTemplate" id="tpl6" value="tpl6" /></td></tr>

</table>	
	
</td></tr>

<tr height="40"><td>

<input type="image" src="images/button_next.png" onClick="showConfirm(event);" onMouseOver="this.src='images/button_next.png'" onMouseOut="this.src='images/button_next.png'" width="175" height="58" border="0" name="submit" alt="Make payments with PayPal - it's fast, free and secure!" />
</td></tr>

</table>
</form>

<?php 

// just fill radio button
Common::fillForm($outputArray); 

?>


</div>

    </div>
    
	<!-- end #mainCol --></div>
	<!-- This clearing element should immediately follow the #mainCol div in order to force the #container div to contain all child floats --><br class="clearfloat" />


<!-- end #twoColContainer --></div>
<?php include ('includes/footer.html');?>
<!-- end #container --></div>


</body>
</html>

<?php
}
 ?>
